The present invention relates to the field of devices for generating vector products and, more particularly, to devices for efficiently generating vector cross products and dot products in computer graphics systems.
Rendering of realistic images (e.g., two- or three-dimensional images) is one of the main goals of graphics system designers. Rendering images of real or imaginary objects typically involves generating geometric models (e.g., polygons) of the objects and applying lighting effects to the polygonal surfaces. In computer graphics, surfaces of an object are generally modeled by a polygonal mesh, which is a collection of vertices, edges, and/or polygons. A mesh of polygons may be produced from a variety of sources such as an application, tesselated NURBS surfaces, spheres, cones, etc. The vertices may be connected by edges and a sequence of edges or vertices may define one or more polygons.
Rendering of realistic 3D graphics requires accurate and efficient modeling of 3D surfaces based upon the position, orientation, and characteristics of the surfaces and the light sources illuminating them. In particular, the interaction between lights and surfaces must be modeled for rendering. To more accurately model lighting effects, conventional computer graphics systems have typically implemented shading techniques to generate light values at individual pixels using an illumination or lighting model.
Conventional lighting models typically model one or more lighting effects such as diffuse reflection, specular reflection, and spotlighting, each of which is typically determined by evaluating a dot product of two vectors. Diffuse reflection accounts for reflection of light from a surface, especially a dull, matte surface. The reflected light from the surface falls off approximately uniformly as a function of an angle between N and L, where N is the outward normal vector at a surface point and L is a light vector. The light vector L points in the direction from the surface point to the light source. The diffuse light fall-off in the diffuse reflection model is typically modeled by using a dot product term N●L.
Similarly, the specular reflection accounts for reflection of light off a shiny surface. When a light from a light source is reflected off a shiny surface, the reflected light is modeled as falling off exponentially from a direction of reflection vector R as seen from a direction of view vector V. For example, the fall-off may be modeled by cossα, where S is a surface material's specular-reflection coefficient and a is an angle between vectors R and V. In practice, a dot product term (N●H)s is often used in place of cossα to model specular reflection at a surface point, where N is a normal vector and H is a half-angle vector.
The spotlight model, on the other hand, adds a direction to a positional light source to allow modeling of directional lights. That is, a spotlight is a special type of light source that has a direction as well as a position. For example, a positional light source may function as a spotlight by restricting the shape of the light to a cone. The direction of the spotlight is the direction in which the light points. The spotlight thereby simulates a cone of light, which may have a fall-off in intensity based upon the distance from the center of the cone of light. As is well known in the art, a spotlight value is typically computed in accordance with a basic spotlight equation, spotlight=(S●L)exp, where S represents a spotlight source direction vector, L represents the vector from a point on the surface to the light source, and exp is a spotlight exponent. The spotlight equation may also include other well-known variables such as attenuation, shadow, etc.
The diffuse, specular, and spotlight models are well known and: are described in greater detail in Computer Graphics: Principles and Practice by James D. Foley et al., Addison-Wesley (1996), ISBN 0-201-84840-6, which is incorporated herein by reference. Additionally, the OpenGL™ (versions 1.1 and 1.2) application programming interface (API) describes various lighting models such as spotlighting, diffuse light reflection, specular light reflection, and related parameters for implementing such models. The OpenGL™ (versions 1.1 and 1.2) graphics application programming interface is commercially available from Silicon Graphics, Inc., the assignee of the present application, and is incorporated herein by reference.
Lighting models often include diffuse, specular, and spotlight units for evaluating the diffuse, specular, and spotlight values. For example, U.S. patent application Ser. No. 09/265,507 entitled “Method and Device for Generating Per-Pixel Values” by inventors David C. Tannenbaum et al. describes a lighting subsystem that includes a diffuse light unit, a specular light unit, and a spotlight unit, for determining the diffuse, specular, and spotlight values. Each of these units evaluates a dot product of vectors (e.g., N, L, S) for computing lighting values.
In computer graphics, however, evaluating light values often requires computing cross products of two vectors. For example, cross products are evaluated to find a vector that is at right angles, i.e., a normal vector, to two other vectors. The normal vectors such as N are routinely used in evaluating light values as described above.
A surface normal vector N at a point P (e.g., vertex, pixel, etc.) may be determined from a pair of vectors originating at the point to associated target points. Unless these vectors are parallel to each other, the vectors define a plane. In practice, the pair of vectors may be obtained by coordinates of the original point to the target coordinates of the associated vectors. Evaluating a cross product of these vectors yields a normal vector that may be used as a surface normal vector depending, for example, on the view direction and the order of the cross product.
Conventional computer graphics systems typically evaluate cross products by using general purpose processors or dedicated cross product units. These approaches, however, may degrade performance or add substantial cost. For example, given that normal vectors can be computed for thousands or even millions of points in a scene, employing the general purpose processors to evaluate cross products may significantly limit the performance of the computer graphics systems. On the other hand, using a cross product unit dedicated to evaluating cross products may be costly to implement within the limited die size of integrated circuit chips.
Thus, what is needed is a device and method for efficiently evaluating cross products of vectors without the performance penalty of the general purpose processors or the cost associated with dedicated cross product units.